﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;

namespace SchEdu.Framework.DataModel
{
    public class SetupTimeList : List<SchEduDataSet.SetupTimeRow>
    {
        public SetupTimeList()
        {
        }

        public SetupTimeList(SetupTimeList setupTimes)
            : base(setupTimes)
        {
        }

        public SetupTimeList(SchEduDataSet.SetupTimeRow[] setupTimes)
        {
            foreach (SchEduDataSet.SetupTimeRow setupTime in setupTimes)
            {
                this.Add(setupTime);
            }
        }

        public SetupTimeList(SchEduDataSet.SetupTimeDataTable setupTimeTable)
        {
            foreach (SchEduDataSet.SetupTimeRow setupTime in setupTimeTable)
            {
                this.Add(setupTime);
            }
        }

        public SetupTimeList GetSetupTime(SchEduDataSet.OrderRow fromOrder,
                                            SchEduDataSet.OrderRow toOrder,
                                            SchEduDataSet.MachineRow machine)
        {
            SetupTimeList setupTimeList = new SetupTimeList();
            foreach (SchEduDataSet.SetupTimeRow st in this)
            {
                if (st.FromOrderID == fromOrder.ID && st.ToOrderID == toOrder.ID &&
                    st.MachineID == machine.ID)
                {
                    setupTimeList.Add(st);
                }
            }
            return setupTimeList;
        }

    }
}
